<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%category}}".
 *
 * @property integer $id
 * @property integer $uid
 * @property integer $sort
 * @property string $title
 * @property integer $num
 */
class Category extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%category}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['uid', 'vid', 'sort', 'title'], 'required'],
            [['uid', 'vid', 'sort', 'num'], 'integer'],
            [['title'], 'string', 'max' => 40],
        ];
    }


    public function getVotes()
    {
        return $this->hasMany(VotePlayer::className(), ['cid' => id]);
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'uid' => '公众号ID',
            'vid' => '活动',
            'sort' => '排序',
            'title' => '标题',
            'num' => '可选数量',
        ];
    }
}
